#!/bin/sh

#  This file is part of Elixir, a source code cross-referencer.
#
#  Copyright (C) 2019--2020 Michael Opdenacker and contributors
#
#  Elixir is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Affero General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  Elixir is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Affero General Public License for more details.
#
#  You should have received a copy of the GNU Affero General Public License
#  along with Elixir.  If not, see <http://www.gnu.org/licenses/>.

root=$1

if [ ! -e "$root" ]
then
    echo "ERROR: directory not found: $root"
    exit 1
fi

if [ -z "$ELIXIR_INSTALL" ]; then
    echo "ERROR: ELIXIR_INSTALL environment variable not set"
    exit 1
fi

for p in linux u-boot busybox zephyr musl barebox uclibc-ng arm-trusted-firmware amazon-freertos qemu glibc coreboot llvm mesa ofono op-tee dpdk toybox grub bluez; do
    echo "Processing project $root/$p ..."
    export LXR_DATA_DIR=$root/$p/data
    export LXR_REPO_DIR=$root/$p/repo

    cd $LXR_REPO_DIR
    git fetch --all --tags

    cd $ELIXIR_INSTALL
    ./update.py $ELIXIR_THREADS
done
